package cn.trda.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import cn.trda.constants.WebConstants;
import cn.trda.pojo.Accountdetail;
import cn.trda.pojo.User;
import cn.trda.service.AccountDetailService;
import cn.trda.util.MySqlPageUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("accountdetail/")
public class AccountDetailController extends BaseController{
	@Autowired
	AccountDetailService accountDetailService;
	
	
	@RequestMapping("view")
	public String getView(){
		return "accountdetail";
	}
	
	@ResponseBody
	@RequestMapping("list")
	public Map<String,Object> getAccountdetailList(Accountdetail accountDetail,Integer page,Integer rows,HttpSession session) throws Exception{
		User user=(User) session.getAttribute(WebConstants.SESSION_USER_KEY);
		accountDetail.setUserid(user.getId());
		accountDetail.setUsername(user.getUsername());
		Map<String,Object> map=new HashMap<String,Object>();
		System.out.println(page+":"+rows);
		List<Accountdetail> list=accountDetailService.getAccountDetailList(accountDetail, page, rows);
		map.put("rows", list);
		int count=accountDetailService.getCount(accountDetail);
		map.put("total", count);
		return map;
	}
}
